package com.Java.train.business.controller.daily;

import com.Java.train.common.response.CommonResp;
import com.Java.train.business.entity.DTO.DailyTrainTicketDTO;
import com.Java.train.business.req.daily.DailyTrainTicketQueryReq;
import com.Java.train.common.response.PageResp;
import com.Java.train.business.entity.DailyTrainTicket;
import com.Java.train.business.service.daily.DailyTrainTicketService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;

/**
* @author luomoxingchen
* @since 2024-10-01
*/
@RestController
@RequestMapping("/admin/daily-train-ticket")
public class DailyTrainTicketController {

    @Autowired
    private DailyTrainTicketService dailyTrainTicketService;


    @GetMapping("/query-list")
    @ApiOperation("DailyTrainTicket查询全部")
    public CommonResp< PageResp<DailyTrainTicketDTO>> queryList(@Valid DailyTrainTicketQueryReq dailyTrainTicketQueryReq){
        PageResp<DailyTrainTicketDTO> list = dailyTrainTicketService.queryList(dailyTrainTicketQueryReq);
        return new CommonResp<>(list);
    }

    @PostMapping("/save")
    @ApiOperation("DailyTrainTicket修改")
    public CommonResp<Object> update(@Valid @RequestBody DailyTrainTicket dailyTrainTicket) {
        return dailyTrainTicketService.modify(dailyTrainTicket);
    }


    @DeleteMapping(value = "/delete/{ids}")
    @ApiOperation("DailyTrainTicket删除(单个条目)")
    public CommonResp<Object> remove(@NotBlank(message = "{required}") @PathVariable String ids) {
        return dailyTrainTicketService.remove(ids);
    }
}
